package news.web;

import news.model.*;
import news.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(path = "/admin/admin")
public class UserController {

    @Autowired
    UserService userService;
    @PostMapping(path = "/users")
    public CommonResult users(@RequestBody User user){
        List<User> users = userService.userList(user);
        CommonResult commonResult = new CommonResult(200,users,"查询成功");
        return commonResult;
    }

    @PostMapping(path = "/changeStatus")
    public CommonResult changeStatus(Integer id,Integer status){
        userService.changeStatus(id,status);
        CommonResult commonResult = new CommonResult(200,"修改成功");
        return commonResult;
    }

    @GetMapping("/selectUrl")
    public CommonResult selectUrl(String account){
        String url = userService.selectUrl(account);
        return new CommonResult(200,url,"查询url");
    }
}
